Ext.define('Admin.view.logger.LoggerGrid', {
    extend: 'Ext.grid.Panel',
    xtype: 'loggerGrid',
    id: 'loggerGrid',

    title: '日志记录',
    iconCls: 'x-fa fa-edit',

    controller: 'loggerViewController',

    viewModel: {
        type: 'loggerViewModel'
    },

    bind: '{logList}',

    columns: [{
            header: 'id',
            dataIndex: 'id',
            width: 80,
            sortable: true,
            hidden: true
        }, {
            header: '姓名',
            dataIndex: 'fullname',
            width: 90,
            sortable: true
        },
        {
            header: '时间',
            dataIndex: 'oprateTime',
            width: 120,
            sortable: true,
            renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s'),
            flex: 1
        }, {
            header: '操作',
            dataIndex: 'oprate',
            width: 140,
            sortable: true,
            flex: 1
        },
        {
            header: 'IP地址',
            dataIndex: 'ip',
            width: 140,
            sortable: true
        },
        {
            header: '结果',
            dataIndex: 'success',
            width: 50,
            sortable: true,
            renderer: function(value) {
                if (value) {
                    return '成功';
                } else {
                    return '失败';
                }
            }
        }
    ],

    tbar: Ext.create('Ext.toolbar.Toolbar', {
        items: [{
            xtype: 'combobox',
            reference: 'logQueryBox',
            queryMode: 'local',
            displayField: 'key',
            valueField: 'value',
            emptyText: '请选择...',
            editable: false,
            allowBlank: false,
            store: Ext.create('Ext.data.Store', {
                fields: ['key', 'value'],
                data: [
                    { "key": '姓名', "value": 'fullname' },
                    { "key": '操作', "value": 'oprate' },
                    { "key": 'IP地址', "value": 'ip' }
                ]
            })
        }, {
            xtype: 'textfield',
            reference: 'logSearchQuery',
            emptyText: '关键字'
        }, {
            text: '重置',
            listeners: {
                click: 'onClickLoggerGridResetButton'
            }
        }, {
            text: '提交',
            listeners: {
                click: 'onClickLoggerGridSearchButton'
            }
        },'->',{
            text: '导出EXCEL',
            listeners: {
                click: 'onClickLoggerGridExportButton'
            }
        }]
    }),

    bbar: Ext.create('Ext.PagingToolbar', {
        bind: '{logList}',
        displayInfo: true,
        displayMsg: '显示第 {0} - {1} 条数据 总计 {2}',
        emptyMsg: "没有任何数据",
    })
});